import os;

sel = ('10-1', '10-2', '6-2', '4-2', '2-2', '2-4', '2-6', '2-10', '1-10');
for i in (1,):
	for j in sel:
		for k in sel:
			s = 'joinroute_sampling-var-100-n-3-'+str(i)+'/js5/ss_real'+j+'/ss_used'+k+'/route0/';
			s1 = '~/joinstats.exe '+s;
			print('Running: '+s1);
			os.system(s1); 

			s1 = '~/analyze_joinsel.exe '+s;
 			print('Running: '+s1);
			os.system(s1);

lines = [];
line_sel = [];

for i in (1,):
	index_i = 0;

        for j in sel:
		lines[index_i:index_i] = [[]];
		line_sel[index_i:index_i] = [[]];

		index_j = 0;

                for k in sel:
			lines[index_i][index_j:index_j] = [[]];
			line_sel[index_i][index_j:index_j] = [[]];

                        s = '/home/DBGROUP/svilen/joinroute_sampling-var-100-n-3-'+str(i)+'/js5/ss_real'+j+'/ss_used'+k+'/route0/'; 			
			try:
				f = open(s+'joinstats.txt', 'r');
				lines[index_i][index_j] = f.readlines();
				f.close();
			except:
				lines[index_i][index_j] = ['0 0 0']*24;

                        try:
                                f = open(s+'joinstats_n.txt', 'r');
                                line_sel[index_i][index_j] = f.readlines();
                                f.close();
                        except:
                                line_sel[index_i][index_j] = ['0 0 0 0 0 0 0 0 0 0 0'];

			
			index_j += 1;

		index_i += 1;

fo = open('output_int.txt', 'w');
for index_i in range(0, 9):
	for k in range(0, 24):
		for index_j in range(0, 9):
			fo.write(lines[index_i][index_j][k].split('\n')[0]+' ');
		fo.write('\n');
	fo.write('\n\n\n\n');		
fo.close();

fo = open('output_int_n.txt', 'w');
for index_i in range(0, 9):
	for index_j in range(0, 9):
                fo.write(line_sel[index_i][index_j][0].split('\n')[0]+'\n');
        fo.write('\n\n\n');
fo.close();
